from datetime import datetime
import random
import re
from typing import Type

SerializableDBType = int | float | str

def generate_hex_str(num: int) -> str:
    # 生成随机的6位十六进制字符串
    hex_string = ''.join(random.choice('0123456789abcdef') for _ in range(num))
    return hex_string

def print_static_vars(cls: Type) -> None:
    print({k:v for k,v in vars(cls).items() if not callable(v) and not k.startswith("__")})

pattern = r'(\d{4})_(\d{2})_(\d{2})_(\d{2})_(\d{2})_(\d{2})'

def capture_to_datetime(capture: str) -> datetime:
    match = re.search(pattern, capture)
    if match:
        year, month, day, hour, minute, second = map(int, match.groups())
        return datetime(year, month, day, hour, minute, second)
    else:
        raise ValueError(f'Invalid capture string: {capture}')
